#! /usr/bin/bash

SCHEDULER="hsJobStart.py"

if [ ! -f "./config/config.cfg" ]; then
  cp ./config/config-default.cfg ./config/config.cfg
  echo "请先配置$(pwd)/config/config.cfg"
  exit 0
fi

echo "开始执行$SCHEDULER"

old_pid=$(pgrep -f $SCHEDULER)

if [ "$old_pid" ]; then
  pgrep -f $SCHEDULER | xargs kill -9
fi

python ./src/$SCHEDULER &

sleep 3
new_pid=$(pgrep -f $SCHEDULER)
echo "pid=$new_pid"
echo "完毕"
kill -2 "$new_pid"
